package com.coocaa.typhoon.api.v1.kafka;

import com.alibaba.fastjson.JSONObject;
import com.coocaa.cirrus.common.base.model.RespBase;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author bijiahao
 * @date : 2025/10/21 15:36
 * @description
 */
@RestController
@RequestMapping("/v1/kafka")
@Tag(name = "Kafka测试")
public class TestKafkaController {

    @Autowired
    private KafkaTemplate<String, String> kafkaTemplate;

    @Operation(summary = "测试上报kafka")
    @PostMapping(value = "/sendTopic")
    public RespBase<Object> sendTopic(@RequestBody JSONObject data) {
        kafkaTemplate.send("test_1", data.toJSONString());
        return new RespBase().setSuccessResult();
    }

}
